import type {ValueOf} from 'type-fest';
import type {
    ReportFieldDateKey,
    ReportFieldKey,
    ReportFieldNegatedKey,
    ReportFieldTextKey,
    SearchAmountFilterKeys,
    SearchDateFilterKeys,
    SearchGroupBy,
    SearchWithdrawalType,
} from '@components/Search/types';
import CONST from '@src/CONST';
import type {SearchDataTypes} from '@src/types/onyx/SearchResults';
import type Form from './Form';

const DATE_FILTER_KEYS: SearchDateFilterKeys[] = [
    CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE,
    CONST.SEARCH.SYNTAX_FILTER_KEYS.SUBMITTED,
    CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED,
    CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID,
    CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED,
    CONST.SEARCH.SYNTAX_FILTER_KEYS.POSTED,
    CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN,
];

const AMOUNT_FILTER_KEYS: SearchAmountFilterKeys[] = [CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT, CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL, CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT];

const FILTER_KEYS = {
    POLICY_ID: 'policyID',
    GROUP_BY: 'groupBy',
    TYPE: 'type',
    STATUS: 'status',

    DATE_NOT: 'dateNot',
    DATE_ON: 'dateOn',
    DATE_AFTER: 'dateAfter',
    DATE_BEFORE: 'dateBefore',

    SUBMITTED_NOT: 'submittedNot',
    SUBMITTED_ON: 'submittedOn',
    SUBMITTED_AFTER: 'submittedAfter',
    SUBMITTED_BEFORE: 'submittedBefore',

    APPROVED_NOT: 'approvedNot',
    APPROVED_ON: 'approvedOn',
    APPROVED_AFTER: 'approvedAfter',
    APPROVED_BEFORE: 'approvedBefore',

    PAID_NOT: 'paidNot',
    PAID_ON: 'paidOn',
    PAID_AFTER: 'paidAfter',
    PAID_BEFORE: 'paidBefore',

    EXPORTED_NOT: 'exportedNot',
    EXPORTED_ON: 'exportedOn',
    EXPORTED_AFTER: 'exportedAfter',
    EXPORTED_BEFORE: 'exportedBefore',

    POSTED_NOT: 'postedNot',
    POSTED_ON: 'postedOn',
    POSTED_AFTER: 'postedAfter',
    POSTED_BEFORE: 'postedBefore',

    WITHDRAWAL_TYPE_NOT: 'withdrawalTypeNot',
    WITHDRAWAL_TYPE: 'withdrawalType',

    WITHDRAWN_NOT: 'withdrawnNot',
    WITHDRAWN_ON: 'withdrawnOn',
    WITHDRAWN_AFTER: 'withdrawnAfter',
    WITHDRAWN_BEFORE: 'withdrawnBefore',

    CURRENCY_NOT: 'currencyNot',
    CURRENCY: 'currency',
    GROUP_CURRENCY: 'groupCurrency',

    CATEGORY_NOT: 'categoryNot',
    CATEGORY: 'category',

    CARD_ID_NOT: 'cardIDNot',
    CARD_ID: 'cardID',

    FEED_NOT: 'feedNot',
    FEED: 'feed',

    MERCHANT_NOT: 'merchantNot',
    MERCHANT: 'merchant',

    DESCRIPTION_NOT: 'descriptionNot',
    DESCRIPTION: 'description',

    REPORT_ID_NOT: 'reportIDNot',
    REPORT_ID: 'reportID',

    AMOUNT_NOT: 'amountNot',
    AMOUNT_EQUAL_TO: 'amountEqualTo',
    AMOUNT_LESS_THAN_NOT: 'amountLessThanNot',
    AMOUNT_LESS_THAN: 'amountLessThan',
    AMOUNT_GREATER_THAN: 'amountGreaterThan',

    TOTAL_NOT: 'totalNot',
    TOTAL_EQUAL_TO: 'totalEqualTo',
    TOTAL_LESS_THAN: 'totalLessThan',
    TOTAL_GREATER_THAN: 'totalGreaterThan',

    TAX_RATE_NOT: 'taxRateNot',
    TAX_RATE: 'taxRate',

    EXPENSE_TYPE_NOT: 'expenseTypeNot',
    EXPENSE_TYPE: 'expenseType',

    TAG_NOT: 'tagNot',
    TAG: 'tag',

    KEYWORD: 'keyword',

    FROM_NOT: 'fromNot',
    FROM: 'from',

    TO_NOT: 'toNot',
    TO: 'to',

    PAYER_NOT: 'payerNot',
    PAYER: 'payer',

    EXPORTER_NOT: 'exporterNot',
    EXPORTER: 'exporter',

    IN_NOT: 'inNot',
    IN: 'in',

    TITLE_NOT: 'titleNot',
    TITLE: 'title',

    ASSIGNEE_NOT: 'assigneeNot',
    ASSIGNEE: 'assignee',

    REIMBURSABLE_NOT: 'reimbursableNot',
    REIMBURSABLE: 'reimbursable',

    BILLABLE_NOT: 'billableNot',
    BILLABLE: 'billable',

    ACTION_NOT: 'actionNot',
    ACTION: 'action',

    HAS_NOT: 'hasNot',
    HAS: 'has',

    IS_NOT: 'isNot',
    IS: 'is',

    PURCHASE_AMOUNT_NOT: 'purchaseAmountNot',
    PURCHASE_AMOUNT_EQUAL_TO: 'purchaseAmountEqualTo',
    PURCHASE_AMOUNT_LESS_THAN_NOT: 'purchaseAmountLessThanNot',
    PURCHASE_AMOUNT_LESS_THAN: 'purchaseAmountLessThan',
    PURCHASE_AMOUNT_GREATER_THAN: 'purchaseAmountGreaterThan',

    PURCHASE_CURRENCY_NOT: 'purchaseCurrencyNot',
    PURCHASE_CURRENCY: 'purchaseCurrency',

    WITHDRAWAL_ID_NOT: 'withdrawalIDNot',
    WITHDRAWAL_ID: 'withdrawalID',

    ATTENDEE_NOT: 'attendeeNot',
    ATTENDEE: 'attendee',
    REPORT_FIELD: 'reportField',
} as const;

const ALLOWED_TYPE_FILTERS = {
    [CONST.SEARCH.DATA_TYPES.EXPENSE]: [
        FILTER_KEYS.TYPE,
        FILTER_KEYS.STATUS,
        FILTER_KEYS.FROM,
        FILTER_KEYS.FROM_NOT,
        FILTER_KEYS.TO,
        FILTER_KEYS.TO_NOT,
        FILTER_KEYS.KEYWORD,
        FILTER_KEYS.POLICY_ID,
        FILTER_KEYS.EXPENSE_TYPE,
        FILTER_KEYS.EXPENSE_TYPE_NOT,
        FILTER_KEYS.MERCHANT,
        FILTER_KEYS.MERCHANT_NOT,
        FILTER_KEYS.DATE_ON,
        FILTER_KEYS.DATE_NOT,
        FILTER_KEYS.DATE_AFTER,
        FILTER_KEYS.DATE_BEFORE,
        FILTER_KEYS.AMOUNT_EQUAL_TO,
        FILTER_KEYS.AMOUNT_NOT,
        FILTER_KEYS.AMOUNT_GREATER_THAN,
        FILTER_KEYS.AMOUNT_LESS_THAN,
        FILTER_KEYS.TOTAL_EQUAL_TO,
        FILTER_KEYS.TOTAL_NOT,
        FILTER_KEYS.TOTAL_GREATER_THAN,
        FILTER_KEYS.TOTAL_LESS_THAN,
        FILTER_KEYS.CURRENCY,
        FILTER_KEYS.CURRENCY_NOT,
        FILTER_KEYS.GROUP_CURRENCY,
        FILTER_KEYS.CATEGORY,
        FILTER_KEYS.CATEGORY_NOT,
        FILTER_KEYS.TAG,
        FILTER_KEYS.TAG_NOT,
        FILTER_KEYS.PAYER,
        FILTER_KEYS.PAYER_NOT,
        FILTER_KEYS.DESCRIPTION,
        FILTER_KEYS.DESCRIPTION_NOT,
        FILTER_KEYS.CARD_ID,
        FILTER_KEYS.CARD_ID_NOT,
        FILTER_KEYS.FEED,
        FILTER_KEYS.FEED_NOT,
        FILTER_KEYS.POSTED_AFTER,
        FILTER_KEYS.POSTED_BEFORE,
        FILTER_KEYS.POSTED_ON,
        FILTER_KEYS.POSTED_NOT,
        FILTER_KEYS.WITHDRAWAL_TYPE,
        FILTER_KEYS.WITHDRAWAL_TYPE_NOT,
        FILTER_KEYS.WITHDRAWN_AFTER,
        FILTER_KEYS.WITHDRAWN_BEFORE,
        FILTER_KEYS.WITHDRAWN_ON,
        FILTER_KEYS.WITHDRAWN_NOT,
        FILTER_KEYS.TAX_RATE,
        FILTER_KEYS.TAX_RATE_NOT,
        FILTER_KEYS.REIMBURSABLE,
        FILTER_KEYS.REIMBURSABLE_NOT,
        FILTER_KEYS.BILLABLE,
        FILTER_KEYS.BILLABLE_NOT,
        FILTER_KEYS.REPORT_ID,
        FILTER_KEYS.REPORT_ID_NOT,
        FILTER_KEYS.SUBMITTED_ON,
        FILTER_KEYS.SUBMITTED_NOT,
        FILTER_KEYS.SUBMITTED_AFTER,
        FILTER_KEYS.SUBMITTED_BEFORE,
        FILTER_KEYS.APPROVED_ON,
        FILTER_KEYS.APPROVED_NOT,
        FILTER_KEYS.APPROVED_AFTER,
        FILTER_KEYS.APPROVED_BEFORE,
        FILTER_KEYS.PAID_ON,
        FILTER_KEYS.PAID_NOT,
        FILTER_KEYS.PAID_AFTER,
        FILTER_KEYS.PAID_BEFORE,
        FILTER_KEYS.EXPORTED_ON,
        FILTER_KEYS.EXPORTED_NOT,
        FILTER_KEYS.EXPORTED_AFTER,
        FILTER_KEYS.EXPORTED_BEFORE,
        FILTER_KEYS.EXPORTER,
        FILTER_KEYS.EXPORTER_NOT,
        FILTER_KEYS.GROUP_BY,
        FILTER_KEYS.ACTION,
        FILTER_KEYS.ACTION_NOT,
        FILTER_KEYS.HAS,
        FILTER_KEYS.HAS_NOT,
        FILTER_KEYS.PURCHASE_AMOUNT_EQUAL_TO,
        FILTER_KEYS.PURCHASE_AMOUNT_NOT,
        FILTER_KEYS.PURCHASE_AMOUNT_GREATER_THAN,
        FILTER_KEYS.PURCHASE_AMOUNT_LESS_THAN,
        FILTER_KEYS.PURCHASE_CURRENCY,
        FILTER_KEYS.PURCHASE_CURRENCY_NOT,
        FILTER_KEYS.WITHDRAWAL_ID,
        FILTER_KEYS.WITHDRAWAL_ID_NOT,
        FILTER_KEYS.TITLE,
        FILTER_KEYS.TITLE_NOT,
        FILTER_KEYS.ATTENDEE,
        FILTER_KEYS.REPORT_FIELD,
        FILTER_KEYS.ATTENDEE_NOT,
    ],
    [CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT]: [
        FILTER_KEYS.TYPE,
        FILTER_KEYS.STATUS,
        FILTER_KEYS.FROM,
        FILTER_KEYS.FROM_NOT,
        FILTER_KEYS.TO,
        FILTER_KEYS.TO_NOT,
        FILTER_KEYS.KEYWORD,
        FILTER_KEYS.POLICY_ID,
        FILTER_KEYS.DATE_ON,
        FILTER_KEYS.DATE_NOT,
        FILTER_KEYS.DATE_AFTER,
        FILTER_KEYS.DATE_BEFORE,
        FILTER_KEYS.TOTAL_EQUAL_TO,
        FILTER_KEYS.TOTAL_NOT,
        FILTER_KEYS.TOTAL_GREATER_THAN,
        FILTER_KEYS.TOTAL_LESS_THAN,
        FILTER_KEYS.CURRENCY,
        FILTER_KEYS.CURRENCY_NOT,
        FILTER_KEYS.GROUP_CURRENCY,
        FILTER_KEYS.PAYER,
        FILTER_KEYS.PAYER_NOT,
        FILTER_KEYS.WITHDRAWAL_TYPE,
        FILTER_KEYS.WITHDRAWAL_TYPE_NOT,
        FILTER_KEYS.WITHDRAWN_AFTER,
        FILTER_KEYS.WITHDRAWN_BEFORE,
        FILTER_KEYS.WITHDRAWN_ON,
        FILTER_KEYS.WITHDRAWN_NOT,
        FILTER_KEYS.REPORT_ID,
        FILTER_KEYS.REPORT_ID_NOT,
        FILTER_KEYS.SUBMITTED_ON,
        FILTER_KEYS.SUBMITTED_NOT,
        FILTER_KEYS.SUBMITTED_AFTER,
        FILTER_KEYS.SUBMITTED_BEFORE,
        FILTER_KEYS.APPROVED_AFTER,
        FILTER_KEYS.APPROVED_BEFORE,
        FILTER_KEYS.APPROVED_ON,
        FILTER_KEYS.APPROVED_NOT,
        FILTER_KEYS.PAID_AFTER,
        FILTER_KEYS.PAID_BEFORE,
        FILTER_KEYS.PAID_ON,
        FILTER_KEYS.PAID_NOT,
        FILTER_KEYS.EXPORTED_AFTER,
        FILTER_KEYS.EXPORTED_BEFORE,
        FILTER_KEYS.EXPORTED_ON,
        FILTER_KEYS.EXPORTED_NOT,
        FILTER_KEYS.EXPORTER,
        FILTER_KEYS.ACTION,
        FILTER_KEYS.ACTION_NOT,
        FILTER_KEYS.WITHDRAWAL_ID,
        FILTER_KEYS.WITHDRAWAL_ID_NOT,
        FILTER_KEYS.TITLE,
        FILTER_KEYS.TITLE_NOT,
        FILTER_KEYS.REPORT_FIELD,
    ],
    [CONST.SEARCH.DATA_TYPES.INVOICE]: [
        FILTER_KEYS.TYPE,
        FILTER_KEYS.STATUS,
        FILTER_KEYS.FROM,
        FILTER_KEYS.FROM_NOT,
        FILTER_KEYS.TO,
        FILTER_KEYS.TO_NOT,
        FILTER_KEYS.KEYWORD,
        FILTER_KEYS.POLICY_ID,
        FILTER_KEYS.MERCHANT,
        FILTER_KEYS.MERCHANT_NOT,
        FILTER_KEYS.DATE_ON,
        FILTER_KEYS.DATE_NOT,
        FILTER_KEYS.DATE_AFTER,
        FILTER_KEYS.DATE_BEFORE,
        FILTER_KEYS.AMOUNT_EQUAL_TO,
        FILTER_KEYS.AMOUNT_NOT,
        FILTER_KEYS.AMOUNT_GREATER_THAN,
        FILTER_KEYS.AMOUNT_LESS_THAN,
        FILTER_KEYS.TOTAL_EQUAL_TO,
        FILTER_KEYS.TOTAL_NOT,
        FILTER_KEYS.TOTAL_GREATER_THAN,
        FILTER_KEYS.TOTAL_LESS_THAN,
        FILTER_KEYS.CURRENCY,
        FILTER_KEYS.CURRENCY_NOT,
        FILTER_KEYS.CATEGORY,
        FILTER_KEYS.CATEGORY_NOT,
        FILTER_KEYS.TAG,
        FILTER_KEYS.TAG_NOT,
        FILTER_KEYS.PAYER,
        FILTER_KEYS.PAYER_NOT,
        FILTER_KEYS.DESCRIPTION,
        FILTER_KEYS.DESCRIPTION_NOT,
        FILTER_KEYS.CARD_ID,
        FILTER_KEYS.CARD_ID_NOT,
        FILTER_KEYS.FEED,
        FILTER_KEYS.FEED_NOT,
        FILTER_KEYS.POSTED_AFTER,
        FILTER_KEYS.POSTED_BEFORE,
        FILTER_KEYS.POSTED_ON,
        FILTER_KEYS.POSTED_NOT,
        FILTER_KEYS.WITHDRAWAL_TYPE,
        FILTER_KEYS.WITHDRAWAL_TYPE_NOT,
        FILTER_KEYS.WITHDRAWN_AFTER,
        FILTER_KEYS.WITHDRAWN_BEFORE,
        FILTER_KEYS.WITHDRAWN_ON,
        FILTER_KEYS.WITHDRAWN_NOT,
        FILTER_KEYS.TAX_RATE,
        FILTER_KEYS.TAX_RATE_NOT,
        FILTER_KEYS.REPORT_ID,
        FILTER_KEYS.REPORT_ID_NOT,
        FILTER_KEYS.SUBMITTED_ON,
        FILTER_KEYS.SUBMITTED_NOT,
        FILTER_KEYS.SUBMITTED_AFTER,
        FILTER_KEYS.SUBMITTED_BEFORE,
        FILTER_KEYS.APPROVED_ON,
        FILTER_KEYS.APPROVED_NOT,
        FILTER_KEYS.APPROVED_AFTER,
        FILTER_KEYS.APPROVED_BEFORE,
        FILTER_KEYS.PAID_ON,
        FILTER_KEYS.PAID_NOT,
        FILTER_KEYS.PAID_AFTER,
        FILTER_KEYS.PAID_BEFORE,
        FILTER_KEYS.EXPORTED_ON,
        FILTER_KEYS.EXPORTED_NOT,
        FILTER_KEYS.EXPORTED_AFTER,
        FILTER_KEYS.EXPORTED_BEFORE,
        FILTER_KEYS.EXPORTER,
        FILTER_KEYS.EXPORTER_NOT,
        FILTER_KEYS.ACTION,
        FILTER_KEYS.ACTION_NOT,
        FILTER_KEYS.PURCHASE_AMOUNT_EQUAL_TO,
        FILTER_KEYS.PURCHASE_AMOUNT_NOT,
        FILTER_KEYS.PURCHASE_AMOUNT_GREATER_THAN,
        FILTER_KEYS.PURCHASE_AMOUNT_LESS_THAN,
        FILTER_KEYS.PURCHASE_CURRENCY,
        FILTER_KEYS.PURCHASE_CURRENCY_NOT,
        FILTER_KEYS.WITHDRAWAL_ID,
        FILTER_KEYS.WITHDRAWAL_ID_NOT,
        FILTER_KEYS.TITLE,
        FILTER_KEYS.REPORT_FIELD,
        FILTER_KEYS.TITLE_NOT,
    ],

    [CONST.SEARCH.DATA_TYPES.TRIP]: [
        FILTER_KEYS.TYPE,
        FILTER_KEYS.STATUS,
        FILTER_KEYS.FROM,
        FILTER_KEYS.FROM_NOT,
        FILTER_KEYS.TO,
        FILTER_KEYS.TO_NOT,
        FILTER_KEYS.KEYWORD,
        FILTER_KEYS.POLICY_ID,
        FILTER_KEYS.MERCHANT,
        FILTER_KEYS.MERCHANT_NOT,
        FILTER_KEYS.DATE_ON,
        FILTER_KEYS.DATE_NOT,
        FILTER_KEYS.DATE_AFTER,
        FILTER_KEYS.DATE_BEFORE,
        FILTER_KEYS.AMOUNT_EQUAL_TO,
        FILTER_KEYS.AMOUNT_NOT,
        FILTER_KEYS.AMOUNT_GREATER_THAN,
        FILTER_KEYS.AMOUNT_LESS_THAN,
        FILTER_KEYS.TOTAL_EQUAL_TO,
        FILTER_KEYS.TOTAL_NOT,
        FILTER_KEYS.TOTAL_GREATER_THAN,
        FILTER_KEYS.TOTAL_LESS_THAN,
        FILTER_KEYS.CURRENCY,
        FILTER_KEYS.CURRENCY_NOT,
        FILTER_KEYS.GROUP_CURRENCY,
        FILTER_KEYS.CATEGORY,
        FILTER_KEYS.CATEGORY_NOT,
        FILTER_KEYS.TAG,
        FILTER_KEYS.TAG_NOT,
        FILTER_KEYS.PAYER,
        FILTER_KEYS.PAYER_NOT,
        FILTER_KEYS.DESCRIPTION,
        FILTER_KEYS.DESCRIPTION_NOT,
        FILTER_KEYS.CARD_ID,
        FILTER_KEYS.CARD_ID_NOT,
        FILTER_KEYS.FEED,
        FILTER_KEYS.FEED_NOT,
        FILTER_KEYS.POSTED_AFTER,
        FILTER_KEYS.POSTED_BEFORE,
        FILTER_KEYS.POSTED_ON,
        FILTER_KEYS.POSTED_NOT,
        FILTER_KEYS.TAX_RATE,
        FILTER_KEYS.TAX_RATE_NOT,
        FILTER_KEYS.REPORT_ID,
        FILTER_KEYS.REPORT_ID_NOT,
        FILTER_KEYS.SUBMITTED_ON,
        FILTER_KEYS.SUBMITTED_NOT,
        FILTER_KEYS.SUBMITTED_AFTER,
        FILTER_KEYS.SUBMITTED_BEFORE,
        FILTER_KEYS.APPROVED_ON,
        FILTER_KEYS.APPROVED_NOT,
        FILTER_KEYS.APPROVED_AFTER,
        FILTER_KEYS.APPROVED_BEFORE,
        FILTER_KEYS.PAID_ON,
        FILTER_KEYS.PAID_NOT,
        FILTER_KEYS.PAID_AFTER,
        FILTER_KEYS.PAID_BEFORE,
        FILTER_KEYS.EXPORTED_ON,
        FILTER_KEYS.EXPORTED_NOT,
        FILTER_KEYS.EXPORTED_AFTER,
        FILTER_KEYS.EXPORTED_BEFORE,
        FILTER_KEYS.EXPORTER,
        FILTER_KEYS.EXPORTER_NOT,
        FILTER_KEYS.ACTION,
        FILTER_KEYS.ACTION_NOT,
        FILTER_KEYS.PURCHASE_AMOUNT_EQUAL_TO,
        FILTER_KEYS.PURCHASE_AMOUNT_NOT,
        FILTER_KEYS.PURCHASE_AMOUNT_GREATER_THAN,
        FILTER_KEYS.PURCHASE_AMOUNT_LESS_THAN,
        FILTER_KEYS.PURCHASE_CURRENCY,
        FILTER_KEYS.PURCHASE_CURRENCY_NOT,
        FILTER_KEYS.TITLE,
        FILTER_KEYS.TITLE_NOT,
        FILTER_KEYS.REPORT_FIELD,
    ],

    [CONST.SEARCH.DATA_TYPES.CHAT]: [
        FILTER_KEYS.TYPE,
        FILTER_KEYS.FROM,
        FILTER_KEYS.FROM_NOT,
        FILTER_KEYS.TO,
        FILTER_KEYS.TO_NOT,
        FILTER_KEYS.IN,
        FILTER_KEYS.IN_NOT,
        FILTER_KEYS.KEYWORD,
        FILTER_KEYS.POLICY_ID,
        FILTER_KEYS.DATE_AFTER,
        FILTER_KEYS.DATE_BEFORE,
        FILTER_KEYS.DATE_ON,
        FILTER_KEYS.DATE_NOT,
        FILTER_KEYS.IS,
        FILTER_KEYS.IS_NOT,
        FILTER_KEYS.HAS,
        FILTER_KEYS.HAS_NOT,
    ],

    [CONST.SEARCH.DATA_TYPES.TASK]: [
        FILTER_KEYS.TYPE,
        FILTER_KEYS.STATUS,
        FILTER_KEYS.TITLE,
        FILTER_KEYS.TITLE_NOT,
        FILTER_KEYS.DESCRIPTION,
        FILTER_KEYS.DESCRIPTION_NOT,
        FILTER_KEYS.IN,
        FILTER_KEYS.IN_NOT,
        FILTER_KEYS.FROM,
        FILTER_KEYS.FROM_NOT,
        FILTER_KEYS.ASSIGNEE,
        FILTER_KEYS.ASSIGNEE_NOT,
        FILTER_KEYS.DATE_ON,
        FILTER_KEYS.DATE_NOT,
        FILTER_KEYS.DATE_AFTER,
        FILTER_KEYS.DATE_BEFORE,
    ],
};

type SearchAdvancedFiltersKey = ValueOf<typeof FILTER_KEYS> | ReportFieldKey;

type SearchAdvancedFiltersForm = Form<
    SearchAdvancedFiltersKey,
    {
        [FILTER_KEYS.GROUP_BY]: SearchGroupBy;

        [FILTER_KEYS.TYPE]: SearchDataTypes;

        [FILTER_KEYS.STATUS]: string[] | string;

        [FILTER_KEYS.DATE_AFTER]: string;
        [FILTER_KEYS.DATE_BEFORE]: string;

        [FILTER_KEYS.DATE_ON]: string;
        [FILTER_KEYS.DATE_NOT]: string;

        [FILTER_KEYS.SUBMITTED_ON]: string;
        [FILTER_KEYS.SUBMITTED_NOT]: string;
        [FILTER_KEYS.SUBMITTED_AFTER]: string;
        [FILTER_KEYS.SUBMITTED_BEFORE]: string;

        [FILTER_KEYS.APPROVED_ON]: string;
        [FILTER_KEYS.APPROVED_NOT]: string;
        [FILTER_KEYS.APPROVED_AFTER]: string;
        [FILTER_KEYS.APPROVED_BEFORE]: string;

        [FILTER_KEYS.PAID_ON]: string;
        [FILTER_KEYS.PAID_NOT]: string;
        [FILTER_KEYS.PAID_AFTER]: string;
        [FILTER_KEYS.PAID_BEFORE]: string;

        [FILTER_KEYS.EXPORTED_ON]: string;
        [FILTER_KEYS.EXPORTED_NOT]: string;
        [FILTER_KEYS.EXPORTED_AFTER]: string;
        [FILTER_KEYS.EXPORTED_BEFORE]: string;

        [FILTER_KEYS.POSTED_ON]: string;
        [FILTER_KEYS.POSTED_NOT]: string;
        [FILTER_KEYS.POSTED_AFTER]: string;
        [FILTER_KEYS.POSTED_BEFORE]: string;

        [FILTER_KEYS.WITHDRAWAL_TYPE]: SearchWithdrawalType;
        [FILTER_KEYS.WITHDRAWAL_TYPE_NOT]: SearchWithdrawalType;

        [FILTER_KEYS.WITHDRAWN_ON]: string;
        [FILTER_KEYS.WITHDRAWN_NOT]: string;
        [FILTER_KEYS.WITHDRAWN_AFTER]: string;
        [FILTER_KEYS.WITHDRAWN_BEFORE]: string;

        [FILTER_KEYS.CURRENCY]: string[];
        [FILTER_KEYS.CURRENCY_NOT]: string[];
        [FILTER_KEYS.GROUP_CURRENCY]: string;

        [FILTER_KEYS.CATEGORY]: string[];
        [FILTER_KEYS.CATEGORY_NOT]: string[];

        [FILTER_KEYS.POLICY_ID]: string[];

        [FILTER_KEYS.CARD_ID]: string[];
        [FILTER_KEYS.CARD_ID_NOT]: string[];

        [FILTER_KEYS.FEED]: string[];
        [FILTER_KEYS.FEED_NOT]: string[];

        [FILTER_KEYS.MERCHANT]: string;
        [FILTER_KEYS.MERCHANT_NOT]: string;

        [FILTER_KEYS.DESCRIPTION]: string;
        [FILTER_KEYS.DESCRIPTION_NOT]: string;

        [FILTER_KEYS.REPORT_ID]: string;
        [FILTER_KEYS.REPORT_ID_NOT]: string;

        [FILTER_KEYS.AMOUNT_EQUAL_TO]: string;
        [FILTER_KEYS.AMOUNT_NOT]: string;
        [FILTER_KEYS.AMOUNT_LESS_THAN]: string;
        [FILTER_KEYS.AMOUNT_LESS_THAN_NOT]: string;
        [FILTER_KEYS.AMOUNT_GREATER_THAN]: string;

        [FILTER_KEYS.TOTAL_EQUAL_TO]: string;
        [FILTER_KEYS.TOTAL_NOT]: string;
        [FILTER_KEYS.TOTAL_LESS_THAN]: string;
        [FILTER_KEYS.TOTAL_GREATER_THAN]: string;

        [FILTER_KEYS.KEYWORD]: string;

        [FILTER_KEYS.TAX_RATE]: string[];
        [FILTER_KEYS.TAX_RATE_NOT]: string[];

        [FILTER_KEYS.EXPENSE_TYPE]: string[];
        [FILTER_KEYS.EXPENSE_TYPE_NOT]: string[];

        [FILTER_KEYS.TAG]: string[];
        [FILTER_KEYS.TAG_NOT]: string[];

        [FILTER_KEYS.FROM]: string[];
        [FILTER_KEYS.FROM_NOT]: string[];

        [FILTER_KEYS.PAYER]: string;
        [FILTER_KEYS.PAYER_NOT]: string;

        [FILTER_KEYS.EXPORTER]: string[];
        [FILTER_KEYS.EXPORTER_NOT]: string[];

        [FILTER_KEYS.TO]: string[];
        [FILTER_KEYS.TO_NOT]: string[];

        [FILTER_KEYS.IN]: string[];
        [FILTER_KEYS.IN_NOT]: string[];

        [FILTER_KEYS.TITLE]: string;
        [FILTER_KEYS.TITLE_NOT]: string;

        [FILTER_KEYS.ASSIGNEE]: string[];
        [FILTER_KEYS.ASSIGNEE_NOT]: string[];

        [FILTER_KEYS.REIMBURSABLE]: string;
        [FILTER_KEYS.REIMBURSABLE_NOT]: string;

        [FILTER_KEYS.BILLABLE]: string;
        [FILTER_KEYS.BILLABLE_NOT]: string;

        [FILTER_KEYS.ACTION]: string;
        [FILTER_KEYS.ACTION_NOT]: string;

        [FILTER_KEYS.HAS]: string[];
        [FILTER_KEYS.HAS_NOT]: string[];

        [FILTER_KEYS.IS]: string[];
        [FILTER_KEYS.IS_NOT]: string[];

        [FILTER_KEYS.PURCHASE_AMOUNT_EQUAL_TO]: string;
        [FILTER_KEYS.PURCHASE_AMOUNT_NOT]: string;
        [FILTER_KEYS.PURCHASE_AMOUNT_GREATER_THAN]: string;
        [FILTER_KEYS.PURCHASE_AMOUNT_LESS_THAN]: string;
        [FILTER_KEYS.PURCHASE_AMOUNT_LESS_THAN_NOT]: string;

        [FILTER_KEYS.PURCHASE_CURRENCY]: string[];
        [FILTER_KEYS.PURCHASE_CURRENCY_NOT]: string[];

        [FILTER_KEYS.WITHDRAWAL_ID]: string;
        [FILTER_KEYS.WITHDRAWAL_ID_NOT]: string;

        [FILTER_KEYS.ATTENDEE]: string[];
        [FILTER_KEYS.ATTENDEE_NOT]: string[];
        [FILTER_KEYS.IS]: string[];
        [FILTER_KEYS.HAS]: string[];
        [FILTER_KEYS.REPORT_FIELD]: string;
    } & Record<ReportFieldTextKey, string> &
        Record<ReportFieldDateKey, string> &
        Record<ReportFieldNegatedKey, string>
>;

export type {SearchAdvancedFiltersForm, SearchAdvancedFiltersKey};
export default FILTER_KEYS;
export {DATE_FILTER_KEYS, ALLOWED_TYPE_FILTERS, FILTER_KEYS, AMOUNT_FILTER_KEYS};
